package com.itbaizhan.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author spf
 * @date 2024/3/20
 * @time 21:05
 */
@AllArgsConstructor
@Data
@NoArgsConstructor
public class BaseResult<T> {
    private int code;
    private String message;
    private T data;

    public static <T> BaseResult<T> ok(){
        return new BaseResult<T>(CodeEnum.EXCESS.getCode(), CodeEnum.EXCESS.getMessage(), null);
    }

    public static <T> BaseResult<T> ok(T data){
        return new BaseResult<T>(CodeEnum.EXCESS.getCode(), CodeEnum.EXCESS.getMessage(), data);
    }

    public static <T> BaseResult<T> error(){
        return new BaseResult<T>(CodeEnum.ERROR.getCode(), CodeEnum.ERROR.getMessage(), null);
    }
}
